<template>

  <div>
    <van-nav-bar
      title="修改信息"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">





    <van-cell-group inset>

      <van-button type="primary" @click="jump('/avator')">更换头像</van-button>
      <van-button type="primary" @click="jump('/address')">地址管理</van-button>
      <!-- 输入任意文本 -->
      <van-field v-model="user.name" label="账号" readonly/>
      <!-- 输入手机号，调起手机号键盘 -->
      <van-field v-model="user.phone" type="tel" label="手机号" />
      <!-- 允许输入正整数，调起纯数字键盘 -->
      <van-field v-model="user.sex" type="text" label='性别' />
      <!-- 允许输入数字，调起带符号的纯数字键盘 -->


    </van-cell-group>
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit">
        提交
      </van-button>
    </div>
    </van-form>
  </div>



</template>

<script>
export default {
  name: "edit",
  created(){

    this.loadData()

  },
  setup() {
    const onClickLeft = () => history.back();
    return {
      onClickLeft,
    };



  },
  data(){
    return{
      user:{
        name:"",
        phone:"",
        sex:"",
      }
    }
  },
  methods:{

    loadData(){
      let _this = this
      this.$axios.post("/user/findUserData").then(
        function (response) {
          console.log(response)

          _this.user = response.data.data.user

        }
      )
    },
    onSubmit(){
      let _this = this
       this.$axios.post("/user/editUser",this.user).then(
        function (response) {
          console.log(response)

          _this.user = response.data.data.user

        }
      )
    },
    jump(path){

      this.$router.push(path)
    }
  }
}
</script>


<style scoped>

</style>
